package Com.Hupochuan.Dal.Tab;

import java.util.Hashtable;

import Com.Hupochuan.Dal.DBManager.DBManager;
import Com.Hupochuan.Vo.Play;

public class PlayTab {
	/*
	 * 本类私有对象
	 */
	private DBManager<Play> dbManager = new DBManager<Play>(Play.class);
	
	/*
	 * 单一实例
	 */
	private PlayTab(){}
	private static PlayTab playTab = new PlayTab();
	public static PlayTab getObject(){
		return playTab;
	}
	
	/*
	 * 根据ID 更新数据
	 */
	public int updateDataAddPlayCount(long id){
		//参数部分
		StringBuffer sqlBuff = new StringBuffer();
		Hashtable<String,Object> paraHash = new Hashtable<String,Object>();
		
		//sql语句部分
		sqlBuff.append(" update Play set ");
		sqlBuff.append(" playCount=playCount+1 ");
		sqlBuff.append(" where id=${id} ");
		
		//sql参数部分
		paraHash.put("id",id);
		
		//执行sql 并返回参数
		return dbManager.updateSql(sqlBuff.toString(),paraHash);
	}
	
	/*
	 * 获得播放对象
	 */
	public Play findPlay(long id){
		//参数部分
		Play play = null;
		StringBuffer sqlBuff = new StringBuffer();
		Hashtable<String,Object> paraHash = new Hashtable<String,Object>();
		
		//sql语句部分
		sqlBuff.append(" select * from Play where id=${id} ");
		
		//sql参数部分
		paraHash.put("id",id);
		
		//从列表中获得对象
		play = dbManager.querySqlReturnVo(sqlBuff.toString(),paraHash);
		
		//返回
		return play;
	}
}
